<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>39 | 创建项目</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords"
	content="Modern Responsive web template, Bootstrap Web Templates, Flat Web Templates, Andriod Compatible web template, 
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyErricsson, Motorola web design" />
<script type="application/x-javascript">
	
	 addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } 

</script>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel='stylesheet' type='text/css' />
<!-- Custom CSS -->
<link href="css/style.css" rel='stylesheet' type='text/css' />
<!-- Graph CSS -->
<link href="css/lines.css" rel='stylesheet' type='text/css' />
<link href="css/font-awesome.css" rel="stylesheet">
<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<!-- Nav CSS -->
<link href="css/custom.css" rel="stylesheet">
<!-- Metis Menu Plugin JavaScript -->
<script src="js/metisMenu.min.js"></script>
<script src="js/custom.js"></script>
<!-- Graph JavaScript -->
<script src="js/d3.v3.js"></script>
<script src="js/rickshaw.js"></script>
<style type="text/css">
.myspan {
	color: red;
}
</style>
<script src="js/validate.js"></script>
<script src="js/pruduct_number.js"></script>
<script src="js/sub_lifecycle.js"></script>
<script type="text/javascript">

	window.onload=function(){
	      var lc_text_list = $("#left option").map(function(){return $(this).text();}).get().join(", ");
	      var lc_val_list = $("#left option").map(function(){return $(this).val();}).get().join(", ");
	      document.getElementById("lifecycle_text_sum").value = lc_text_list;
	      document.getElementById("lifecycle_val_sum").value = lc_val_list;
	}
	
	function selectClient() {
		var newWindow = null;
  		if (!newWindow || newWindow.closed) {
	    	var width = 500;
			var height = 300;
	        var left = parseInt((screen.availWidth/2) - (width/2));
	       	var top = parseInt((screen.availHeight/2) - (height/2));
	        var windowFeatures = "width=" + width + ",height=" + height + ",status=no,resizable=0,scrollbars=0,titlebar=0,toolbar=0,location=no,menubar=0,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
	        newWindow = window.open("getAllClient?opcode=alllist_for_project", "subWind", windowFeatures);
	    } else {
	        newWindow.focus();
	    }
	}

	$(document).ready(
			function() {
				$("#add").click(
						function() {
							var value = $("#left option:selected")
									.attr("value");
							if (value != undefined) {
								var selObj = $("#right");
								var text = $("#left").find("option:selected").text();
								selObj.append("<option value='"+value+"'>"
										+ text + "</option>");
								$("#left option:selected").remove();
							}
							var life_cycle_all = $("#right option").map(function(){
		                        return $(this).val();
		                    }).get().join(",");
							$("#hide_life_cycle").val(life_cycle_all);
						});
				$("#delete").click(
						function() {
							var value = $("#right option:selected").attr(
									"value");
							if (value != undefined) {
								var selObj = $("#left");
								var text = $("#right").find("option:selected").text();
								selObj.append("<option value='"+value+"'>"
										+ text + "</option>");
								$("#right option:selected").remove();
							}
							var life_cycle_all = $("#right option").map(function(){
		                        return $(this).val();
		                    }).get().join(",");
							$("#hide_life_cycle").val(life_cycle_all);
						});
			});
			
	    function merge() {
	    	$("#hide_sub_life_cycle").val("");
	    	for(i=0; i < $("input[class='sub_life_c']").length; i++) {
	    		$("#hide_sub_life_cycle").val($("#hide_sub_life_cycle").val() + $("input[class='sub_life_c']")[i].value);
    		}
   		}
   		
		// 点击后弹出添加设备地点的小窗口
   		function add_one_device() {
   			var newWindow = null;
   			if (!newWindow || newWindow.closed) {
		    	var width = 500;
				var height = 300;
		        var left = parseInt((screen.availWidth/2) - (width/2));
		       	var top = parseInt((screen.availHeight/2) - (height/2));
		        var windowFeatures = "width=" + width + ",height=" + height + ",status=no,resizable=0,scrollbars=0,titlebar=0,toolbar=0,location=no,menubar=0,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
		        newWindow = window.open("device_add.jsp", "subWind", windowFeatures);
		    } else {
		        newWindow.focus();
		    }
   		}

   		// 删除某个不要的设备
   		function del_dev(dev_for_del) {
   			var dev_t = document.getElementById("dev_t");
   			dev_t.removeChild(dev_for_del.parentNode.parentNode);
   			count = dev_t.childNodes;
   			if(count.length <= 1) {
   				dev_t.removeChild(dev_t.childNodes.item(0));
   			}
   			var device_count = document.getElementById("device_count");
   			device_count.value = parseInt(device_count.value) - 1;
   		}
   		
		// 合并设备
		function merge_device() {
			var device = new Array();
			var dev_t = document.getElementById("dev_t");
			var table_len = dev_t.childNodes.length;
			for(i=1; i<table_len; i++) {
				device[i-1] = dev_t.childNodes.item(i).childNodes.item(0).innerHTML + "," + dev_t.childNodes.item(i).childNodes.item(1).innerHTML;
			}
			var hidden_device = document.getElementById("hidden_device");
			hidden_device.value = device.join(";");
		}
</script>

</head>
<body>
	<div id="wrapper">
		<!-- Navigation -->
		<!-- left.jsp -->
		<jsp:include page="left.jsp"></jsp:include>
		<div id="page-wrapper">

			<div class="graphs">
				<div class="xs">
					<h3>创建项目</h3>

					<form name="add" method="post" action="createProjectCommit"
						class="form-horizontal">
						<div class="tab-content">
							<div class="tab-pane active" id="horizontal-form">
							
								<div class="form-group">
									<label for="label_project_code" class="col-sm-2 control-label">项目令号</label>
									<div class="col-sm-2">
										<input type="text" name="project.project_code"
											class="form-control1" id="label_project_code">
									</div>
									<span id="span_code" class="myspan"></span>
								</div>
								
									<div class="form-group">
										<label for="label_leader_39" class="col-sm-2 control-label">主管所领导</label>
										<div class="col-sm-3">
											<select name="project.leader_39.id" id="label_leader_39"
												class="form-control1">
												<c:forEach items="${leaderList}" var="leader">
													<option value="${leader.id }">${leader.user_name
														}&nbsp;${leader.user_id}</option>
												</c:forEach>
											</select>
										</div>
										<span id="span_leader" class="myspan"></span>
									</div>
								
								
								
								
								<div class="form-group">
									<label for="label_project_name" class="col-sm-2 control-label">项目名称</label>
									<div class="col-sm-7">
										<input type="text" name="project.project_name"
											class="form-control1" id="label_project_name">
									</div>
									<span id="span_name" class="myspan"></span>
								</div>
                                
                                <div class="form-group">
									<label for="label_project_manager" class="col-sm-2 control-label">计划部分管领导</label>
									<div class="col-sm-3">
										<select name="project.project_manager.id" id="label_project_manager"
											class="form-control1">
											<c:forEach items="${managerList}" var="manager">
												<option value="${manager.id }">${manager.user_name}</option>
											</c:forEach>
										</select>
									</div>
								<div class="form-group">
									<label for="label_cpd" class="col-sm-1 control-label">计划部项目负责人</label>
									<div class="col-sm-3">
										<select name="project.cpd_ps.id" id="label_cpd"
											class="form-control1">
											<c:forEach items="${cpdPsList}" var="cpdPs">
												<option value="${cpdPs.id }">${cpdPs.user_name}</option>
											</c:forEach>
										</select>
									</div>
									<span id="span_cpd_ps" class="myspan"></span>
								</div>
								</div>
								

								<div class="form-group">
									<label for="label_project_type" class="col-sm-2 control-label">项目类型</label>
									<div class="col-sm-3">
										<select name="project.project_type.id" id="label_project_type"
											class="form-control1">
											<c:forEach items="${typeList}" var="type">
												<option value="${type.id }">${type.protype_name}</option>
											</c:forEach>
										</select>
									</div>
									<span id="span_type" class="myspan"></span>
								
								<div class="form-group">
									<label for="label_project_field" class="col-sm-1 control-label">项目领域</label>
									<div class="col-sm-3">
										<select name="project.project_filed.id" id="label_project_field"
											class="form-control1">
											<c:forEach items="${fieldList}" var="field">
												<option value="${field.id }">${field.projectfield_name}</option>
											</c:forEach>
										</select>
									</div>
									<span id="span_field" class="myspan"></span>
								</div>
								</div>
								
								<div class="form-group">
									<label for="label_head_dept" class="col-sm-2 control-label">牵头单位</label>
									<div class="col-sm-3">
										<select name="project.head_dept.id" id="label_head_dept"
											class="form-control1">
											<c:forEach items="${headDeptList}" var="headDept" begin="0" end="6">
												<option value="${headDept.id }">${headDept.dept_name}</option>
											</c:forEach>
										</select>
									</div>
									<span id="span_headdept" class="myspan"></span>
								
								<div class="form-group">
									<label for="label_head_ps" class="col-sm-1 control-label">事业部项目主管</label>
									<div class="col-sm-3">
										<input type="text" name="project.head_ps"
											class="form-control1" id="label_head_ps">
									</div>
									<span id="span_head_ps" class="myspan"></span>			
								</div>
								</div>

								<div class="form-group">
									<label for="label_client" class="col-sm-2 control-label">合同甲方</label>
									
									<div class="col-sm-3">
										<input type="button" onclick="selectClient()" value="选择合同甲方"/>
										<span id="span_selected" style=""></span>
										<input type="hidden" name="project.client.id" value="" id="input_client"/>
									</div>
									<span id="span_client" class="myspan"></span>
								</div>
								
								<div class="form-group">
									<label for="label_consumerunit" class="col-sm-2 control-label">用户单位</label>
									<div class="col-sm-3">
										<input type="text" name="project.consumerunit"
											class="form-control1" id="label_consumerunit">
									</div>
									<span id="span_consumerunit" class="myspan"></span>
								</div>
								
								<div class="form-group">
									<label class="col-sm-2 control-label">参研单位</label>
									<div class="col-sm-3">
										<c:forEach items="${headDeptList}" var="dept" begin="0" end="6">
											<div class="">
												<input type="checkbox" value="${dept.id }" class="participate_dept" name="participate_dept" id="head_dept_${dept.id }"/>
												<label for="head_dept_${dept.id }">${dept.dept_name }</label></div>
										</c:forEach>
									</div>
									<span id="span_participate_dept" class="myspan"></span>
								</div>

								<div class="form-group">
									<label for="label_time_details" class="col-sm-2 control-label">项目启动时间</label>
									<div class="col-sm-2">
										<input type="date" name="project.time_details" id="label_time_details" class="form-control1"/>
									</div>
									<span id="span_time_details" class="myspan"></span>
								</div>

								<div class="form-group">
									<label for="device_count" class="col-sm-2 control-label">设备信息</label>
									<input type="hidden" id="device_count" name="project.product_number" class="form-control1" value=0 readonly="readonly"/>
									&nbsp;
									<input type="button" value="添加一台设备" onclick="add_one_device()"/>
									<span id="span_dev" class="myspan"></span>
								</div>
								<input type="hidden" name="project.product_place" id="hidden_device"/>
								<div class="form-group">
									<div id="dev_div">
										<ul id="dev_ul">
										</ul>
										<table id="dev_t" style="width:50%;" align="center"></table>
									</div>
								</div>

								<div class="form-group">
									<label for="left" class="col-sm-2 control-label">项目生命周期模型</label>
									<div class="col-sm-8">
										<table>
											<tr>
											</tr>
											<tr>
												<td><select size=${fn:length(lifeCycleList) } id="left" style="width:150px" >
													<c:forEach items="${lifeCycleList }" var="lc">
														<option value="${lc.id }">${lc.name_lifecycle }</option>
													</c:forEach>
												</select></td>
												<td>
													<p>
														<%-- <span id="add" style="background-color: blue; color:white">添加</span> --%>
														<input type="button" id="add" value="添加"/>
													</p>
													<p>
														<%-- <span id="delete" style="background-color: blue; color:white">删除</span> --%>
															<input id="delete" type="button" value="删除"/>
													</p></td>
												<td><select size=${fn:length(lifeCycleList) } id="right" style="width:150px"></select>
												</td>
											</tr>
										</table>
									</div>
									<span id="span_lifecycle" class="myspan"></span>
									<input type="hidden" value="" id="lifecycle_text_sum"/>
									<input type="hidden" value="" id="lifecycle_val_sum"/>
								</div>
								
								<div class="form-group">
									<div class="col-sm-8">
										<input type="hidden" name="life_cycle_string"
											class="form-control1" id="hide_life_cycle">
									</div>
								</div>

								<div class="form-group">
									<label for="" class="col-sm-2 control-label">请选择分机生命周期模型</label>
									<div class="col-sm-8">
										<c:forEach var="sub_c" items="${subcycleList }">
											<div class="checkbox-inline">
											<input value="${sub_c.name_subcycle }" type="checkbox" id="${sub_c.id }" class="sub_check">${sub_c.name_subcycle }
											</div>
										</c:forEach>
										<hr>
								    	<div id="sub_div">
								    	</div>
									</div>
									
									<span id="span_subsystem_cycle" class="myspan"></span>
									
									
								</div>
								
								<div class="form-group">
									<label for="focusedinput" class="col-sm-2 control-label">&nbsp;</label>
									<!-- <input type="button" value="合并" id="sub_lifecycle_sum"> -->
								</div>
								
								<div class="form-group">
									<div class="col-sm-5">
										<input type="hidden" readonly="readonly" name="sub_life_cycle_string"
											class="form-control1" id="hide_sub_life_cycle">
									</div>
								</div>
								
								<center>
									<input id="b1" type="button" class="btn btn-primary" value="创建项目" onclick="merge();merge_device();if(validate()) document.add.submit();"/>
									<span id="span_button" style="color:red;"></span>
								</center>
					</form>

				</div>

			</div>
		</div>
		<div class="copy_layout">
			<jsp:include page="copyright.jsp"></jsp:include>
		</div>
	</div>

	<script src="js/bootstrap.min.js"></script>
</body>
</html>
